package com.yuyang.wifi.utils;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

/**
 * created by mej
 * on 2020/12/31
 */
public class AnimationUtils {

    public static void floatAnim(View view, int delay, int firstTime, int secondTime) {
        try {
            List<Animator> animators = new ArrayList<>();
            ObjectAnimator translationXAnim = ObjectAnimator.ofFloat(view, "translationX", 0f, 1f, 0f);
            translationXAnim.setDuration(firstTime);
            translationXAnim.setRepeatCount(ValueAnimator.INFINITE);//无限循环
            //translationXAnim.setRepeatMode(ValueAnimator.INFINITE);//
            translationXAnim.start();
            animators.add(translationXAnim);
            ObjectAnimator translationYAnim = ObjectAnimator.ofFloat(view, "translationY", 0f, 10.0f, 0f);
            translationYAnim.setDuration(secondTime);
            translationYAnim.setRepeatCount(ValueAnimator.INFINITE);
            //translationYAnim.setRepeatMode(ValueAnimator.INFINITE);
            translationYAnim.start();
            animators.add(translationYAnim);

            AnimatorSet btnSexAnimatorSet = new AnimatorSet();
            btnSexAnimatorSet.playTogether(animators);
            btnSexAnimatorSet.setStartDelay(delay);
            btnSexAnimatorSet.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
